<?php
/*
 * @Description    : 验证
 * @Version        : 1.0.0
 * @Author         : QianLong
 * @Date           : 2021-04-16 16:48:24
 * @LastEditors    : QianLong
 * @LastEditTime   : 2024-03-19 10:11:15
 */

namespace app\common;

use app\lib\exception\ApiException;

class Verify
{
  public static function check(array $postData)
  {
    $apiUrl = 'https://21ds.cn/captcha/verify';
    $postData['sign'] = devSignGeneral($postData, '24QGhRTT8nnXm2EhPf2KfzXGrmM8efFCTbPWTZNcshpxciaf2xY6KkA7GfBc4Y7t');
    $http = new \Yurun\Util\HttpRequest;
    $response = $http->post($apiUrl, $postData);
    $result = json_decode($response->body(), true);
    if ($result['code'] != 200) {
      throw new ApiException('安全验证失败，请刷新页面后重试'.json_encode($result));
    }
  }
}